<?php

/**
 *
 * @author Kam
 */
class Application_Model_DAO_Property extends My_DAO_Abstract {

    const DB_PROPERTY = 'Property';

    public function save($name, $value) {
        $where = $this->quoteInto('name = ?', $name);
        $this->getDbTable()->update(array('value' => $value), $where);
    }

    public function getProperties() {
        $rows = $this->getDbTable()->select(Zend_Db_Table::SELECT_WITHOUT_FROM_PART)
                        ->from('property', array('property_id', 'name', 'value', 'type', 'default_value'))
                        ->query()->fetchAll();

        $result = array();
        foreach ($rows as $row) {
            $result[$row['name']] = $row;
        }
        return $result;
    }

    public function getAll() {
        return $this->getDbTable()->select()
                        ->order('name');
    }

    protected function getDbTableNameMap() {
        return array(
            self::DB_PROPERTY => 'Application_Model_DbTable_Property',
        );
    }

    protected function getDefaultDbTableName() {
        return self::DB_PROPERTY;
    }

}
